const timeline  = require('./../server/timeline');
const timeline_ = new timeline();
function timelineHandle() {
    let result = {};
    this.query = (req,res) => {
        timeline_.query(req, rows => {
            if (rows){
                result.code=1;
                result.data = rows;
            } else{
                result.code=0;
                result.data = null;
            }
            res.write(JSON.stringify(result));
            res.end();
        })
    };
    this.add = (req,res) => {
        timeline_.add(req, rows => {
            if (rows){
                result.code=1;
                result.msg = '发布成功';
            } else{
                result.code=0;
                result.data = null;
            }
            res.write(JSON.stringify(result));
            res.end();
        })
    };
}
module.exports = timelineHandle;